import random


# 生成验证码
def codes():
    # 验证码字符串
    code = ''

    for i in range(0, 4):
        # 生成大写字母
        s1 = chr(random.randint(65, 90))
        # 生成小写字母
        s2 = chr(random.randint(97, 122))

        # 随机选择大小写随机数
        s = [s1, s2]
        r = random.choice(s)

        # 拼接验证码，使用空字符串''
        code = ''.join([code, r])
    print(code)


codes()
